#include "problems/23.h"
#include "gtest/gtest.h"

TEST(TestProblemSolutions, TestProblem23)
{
    problem_23::Solution s;

    ListNode n1(1), n2(4), n3(5), n4(1), n5(3), n6(4), n7(2), n8(6);
    n1.next = &n2;
    n2.next = &n3;

    n4.next = &n5;
    n5.next = &n6;

    n7.next = &n8;
    vector<ListNode *> lists{&n1, &n4, &n7};

    auto result = s.mergeKLists(lists);
    vector<int> ans{1, 1, 2, 3, 4, 4, 5, 6};
    for (auto n : ans)
    {
        ASSERT_NE(result, nullptr);
        ASSERT_EQ(result->val, n);
        result = result->next;
    }
}